package com.pucong.gitee.database.backup.database.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.pucong.gitee.database.backup.common.entity.BackupDatabase;
import com.pucong.gitee.database.backup.common.entity.BackupExeSqlLog;
import com.pucong.gitee.database.backup.database.service.BackupDatabaseService;
import com.pucong.gitee.database.backup.database.service.BackupExeSqlLogService;
import com.pucong.gitee.database.backup.utils.Res;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author pucong
 * @company www.louddt.com
 * @create 2020-06-23
 */
@RestController
@RequestMapping("/backup/exeSqlLog")
@Api(value = "sql执行记录信息表-API ", tags = "7. sql执行记录信息表 API")
public class BackupExeSqlLogController {

    @Autowired
    private BackupExeSqlLogService backupExeSqlLogService;

    @GetMapping("/getExeSqlLogListByPage/{pageNum}/{pageSize}")
    @ApiOperation(value = "601分页查询sql执行历史记录", notes = "分页条件查询历史记录")
    public Res<IPage<BackupExeSqlLog>> getExeSqlLogListByPage(@ApiParam(value = "页数",example = "1")@PathVariable("pageNum") int pageNum, @ApiParam(value = "一页大小",example = "10")@PathVariable("pageSize") int pageSize, BackupExeSqlLog backupExeSqlLog){
        IPage<BackupExeSqlLog> backupDatabaseIPage = backupExeSqlLogService.getExeSqlLogListByPage(pageNum,pageSize,backupExeSqlLog);
        return Res.ok(backupDatabaseIPage);
    }

    @GetMapping("/getExeSqlLogById/{id}")
    @ApiOperation(value = "602根据主键查询", notes = "根据主键查询")
    public Res<BackupExeSqlLog> getExeSqlLogById(@ApiParam("主键")@PathVariable("id") String id){
        BackupExeSqlLog backupDatabase = backupExeSqlLogService.getExeSqlLogById(id);
        return Res.ok(backupDatabase);
    }

}
